package library.actions;

import org.eclipse.core.resources.IFile;
import org.eclipse.emf.edit.ui.action.CreateChildAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;

public class LibraryCreateAction extends CreateChildAction {
	private IFile file;

	public LibraryCreateAction(IEditorPart editorPart, ISelection selection,
			Object descriptor) {
		super(editorPart, selection, descriptor);
		IEditorInput editorInput = editorPart.getEditorInput();
		if (editorInput instanceof IFileEditorInput) {
			IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
			file = fileEditorInput.getFile();
		}
	}

	public void run() {
		if (ActionFactory.wizardConfirmed(command, file)) {
			super.run();
		}
	}
}
